﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using qlHieuThuocDongY.DataAccess;

namespace qlHieuThuocDongY
{
    public partial class frmTimKiemThuoc : Form
    {
        public frmTimKiemThuoc()
        {
            InitializeComponent();
        }
        ConnectData conn = new ConnectData();
        private void frmTimKiemThuoc_Load(object sender, EventArgs e)
        {
            dataGridViewTimKiemThuoc.DataSource = conn.GetDataTable("Select * from DanhMucThuoc");
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtNhapTimKiemThuoc.Text.Length == 0)
                dataGridViewTimKiemThuoc.DataSource = conn.GetDataTable("Select * from DanhMucThuoc");
            else
            {
                if (rdMaThuoc.Checked)
                    dataGridViewTimKiemThuoc.DataSource = conn.GetDataTable("Select * from DanhMucThuoc where MaThuoc='" + txtNhapTimKiemThuoc.Text + "'");
                else
                    dataGridViewTimKiemThuoc.DataSource = conn.GetDataTable("Select * from DanhMucThuoc where TenThuoc like N'%" + txtNhapTimKiemThuoc.Text + "%'");
            }

        }
    }
}
